<%@page import="java.util.Date"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="com.mongodb.DBCursor"%>
<%@page import="y1s.controller.Utils"%>
<%@page import="com.mongodb.DBObject"%>
<% request.setCharacterEncoding("utf-8");%>
<%

DBObject domain = (DBObject) request.getAttribute("domain");
DBCursor subdomain = (DBCursor) request.getAttribute("subdomain");
DBCursor googleAnalytic = (DBCursor) request.getAttribute("googleAnalytic");
DBCursor googleAdsense = (DBCursor) request.getAttribute("googleAdsense");
DBCursor inlink = (DBCursor) request.getAttribute("inlink");
DBCursor ip = (DBCursor) request.getAttribute("ip");
DBCursor random = (DBCursor) request.getAttribute("random");
String search = (String) request.getAttribute("search");
String re_title = domain.get("name").toString();
if(domain.get("title") != null)
{
	re_title = domain.get("title").toString();
}
if(re_title.length()>100)
{
	re_title = domain.get("title").toString().substring(0,100);
}
String re_des = domain.get("name").toString();
String re_key = domain.get("name").toString();
if(domain.get("description") != null )
{
	re_des = domain.get("description").toString(); 	
}
if(domain.get("pKeyword") != null )
{
	re_des += Utils.returnText(domain.get("pKeyword").toString());
	re_key += ","+Utils.returnText(domain.get("pKeyword").toString());
}
if(domain.get("keyword") != null )
{
	re_des += Utils.returnText(domain.get("keyword").toString()); 
	re_key += ","+Utils.returnText(domain.get("keyword").toString());
}
re_key += "website,site,5ty,5ty.org,alexa,google pagerank,pagerank,whois,ip,related site,infomation site";

if(re_des.length()>200)
{
	re_des = re_des.substring(0,200);	
}
if(re_key.length()>250)
{
	re_key = re_key.substring(0,250);	
}
String title = domain.get("name")+" "+re_title;
String description = domain.get("name")+" "+re_des;
String keywords = re_key;

NumberFormat nf = NumberFormat.getInstance();

long date = new Date().getTime();
long dates = new Date().getTime();
if(domain.get("update") != null)
{
	dates = Long.parseLong(domain.get("update").toString());
}
long seconds = (date - dates)/1000;
long day = (int) (seconds / 86400);
long hour = (int) ((seconds - day*86400) / 3600);
long minute = (int) ((seconds - day*86400 - hour*3600) / 60);
if(hour<0)
{
	hour = 0;	
}
if(minute<0)
{
	minute = 0;	
}
if(day<0)
{
	day = 0;	
}
String names = domain.get("name").toString();
%>
<%@page contentType="text/html;charset=UTF-8" language="java"%>
<jsp:include page="./layout/header.jsp">
	<jsp:param name="title" value="<%=title %>"/>
	<jsp:param name="description" value="<%=description %>"/>
	<jsp:param name="keywords" value="<%=keywords %>"/>
	<jsp:param name="img" value="<%=names %>"/>
</jsp:include>
		<div class="body">
			<div class="body_left">
				<div class="top_left">
					<%@ include file='/adv/left.jsp'%>
				</div>
				<%@ include file='/element/spot_check.jsp'%>
				<div class="update">
					
				</div>
				<h2>Site random</h2>
				<ul class="left_list">
				<%
				ArrayList<String> siteRandom = (ArrayList<String>)domain.get("siteRandom");
				for(int i=0;i<siteRandom.size();i++)
				{
				%>
					<li><a href="/d/<%=siteRandom.get(i)%>" title="<%=siteRandom.get(i) %>"><%=siteRandom.get(i) %></a></li>
				<%
				}	
				%>
				</ul>
				<div class="de_adv">
					<%@ include file='/adv/left160.jsp'%>
				</div>
			</div>
			<div class="body_right">
				<div class="top">
					<div class="d_name">
					<img src='http://chart.apis.google.com/chart?chs=60x60&cht=qr&chld=|0&chl=http://<%=domain.get("name") %>'/>
					<%=domain.get("name") %>
					</div>
				</div>
				<div class="content">
					<div class="note clear">
					Updated<b>
					<%
						if(day > 0)
						{
							out.print(day+" days, ");
						}
						if(hour > 0)
						{
							out.print(hour+" hours, ");
						}
						out.print(minute+" minutes");
					%>	
					</b> Ago
					<%
					if(day>=2 || domain.get("update") == null)
					{
					%>
								<strong class="size">( <a href="javascript:void(0)" rel="nofollow" id="update">Update</a> )</strong>
					<%
					}
					%>
					<br/>
					<%
					if(domain.get("gmail") != null && domain.get("gmail").toString().equals("1"))
					{
					%>
					<strong><%=domain.get("name") %></strong> use gmail service of google.com
					<%
					}
					%> 
					View <a href="http://ipsite.net/d/<%=domain.get("name") %>" target="_blank" rel="nofollow"><%=domain.get("name") %></a> in ipsite.net
					</div>
					
					<div class="adv">
						<%@ include file='/adv/left.jsp'%>
					</div>
					<div class="list">
						<h1>Ranking info of <%=domain.get("name") %></h1>
						<ul class="detail">
							<li>
								<div class="left w_left">
									Google pagerank :
								</div>
								<div class="right w_right">
									<%=(domain.get("googlePagerank")!=null)?domain.get("googlePagerank"):"-" %>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Alexa rank :
								</div>
								<div class="right w_right">
									<%=(domain.get("rank")!=null && !domain.get("rank").toString().equals("0"))?nf.format(domain.get("rank")):"-" %>
								</div>
							</li>
						</ul>
						<div class="clear"></div>
						<h1 class="m_top">Domain</h1>
						<ul class="detail">
							<li>
								<div class="left w_left">
									Domain name :
								</div>
								<div class="right w_right">
									<strong><%=domain.get("name")%></strong><br/>
									<strong>Length : </strong> <%=Utils.checkLengthDomain(domain.get("name").toString()) %> characters
								</div>
							</li>
							<li>
								<div class="left w_left">
									Subdomain :
								</div>
								<div class="right w_right">
									<strong><%=domain.get("name")%></strong> <%=Utils.returnSubDomain(domain.get("name").toString()) %>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Favicon :
								</div>
								<div class="right w_right">
									<img src="https://s2.googleusercontent.com/s2/favicons?domain_url=http://<%=domain.get("name")%>"/>
								</div>
							</li>
						</ul>
					</div>
					<div class="clear"></div>
					<div class="adv_menu">
						<%@ include file='/adv/menu.jsp'%>
					</div>
					<div class="adv right">
						<%@ include file='/adv/left.jsp'%>
					</div>
					<div class="list margin_3">
						<h1>Site parameters of <%=domain.get("name") %></h1>
						<ul class="detail">
							<li>
								<div class="left w_left">
									Estimate Visitor per Day :
								</div>
								<div class="right w_right">
									<%=(domain.get("visit")!=null && !domain.get("visit").equals("-"))?nf.format(Math.ceil(((350*Float.parseFloat(domain.get("visit").toString().replaceAll("[^0-9.]","")))*80)/0.03))+" - "+nf.format(Math.ceil(((350*Float.parseFloat(domain.get("visit").toString().replaceAll("[^0-9.]","")))*120)/0.03)):"-" %>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Speed site :
								</div>
								<div class="right w_right">
									<%=(domain.get("speed")!=null)?Float.valueOf(domain.get("speed").toString())+" Seconds":"-" %>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Domain Age :
								</div>
								<div class="right w_right">
									<%=(domain.get("age")!=null)?domain.get("age"):"-" %>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Charset :
								</div>
								<div class="right w_right">
									<%=(domain.get("charset")!=null)?domain.get("charset"):"-" %>
								</div>
							</li>
							<li>
								<div class="left w_left">
									WOT :
								</div>
								<div class="right w_right">
									<%=(domain.get("wot")!=null)?domain.get("wot"):"-" %>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Page speed :
								</div>
								<div class="right w_right" id='page_speed'>
									<a href="javascript:void(0)" onclick="runPagespeed()">Check now</a>
								</div>
							</li>
						</ul>
					</div>
					<div class="clear"></div>
					<div class="adv_menu">
						<%@ include file='/adv/menu.jsp'%>
					</div>
					<%
					if(subdomain != null && subdomain.size() > 0)
					{
					%>
					<div class="list re_list">
						<h1 class="m_top">Other domain of <%=Utils.returnSubDomainTo(domain.get("name").toString())  %> ( <a href="/sd/<%=Utils.returnSubDomainTo(domain.get("name").toString())%>">View all</a> )</h1>
						<ul class="detail">
							<li class="sub">
								<%
									while(subdomain.hasNext())
									{
										String name = subdomain.next().get("name").toString();
								%>
										<a href="/d/<%=name %>"><%=name %></a> | 
								<%
									}
								%> 
							</li>
						</ul>
					</div>
					<%
					}
					%>
					<div class="list re_list">
						<h1 class="m_top">Site info of <%=domain.get("name") %></h1>
						<ul class="detail">
							<li>
								<div class="left w_left">
									Title :
								</div>
								<div class="right d_right">
									<%=(domain.get("title")!=null)?domain.get("title"):"-" %><br/>
									<strong>Length : <%=(domain.get("title")!=null)?domain.get("title").toString().length():"0" %></strong>  characters
								</div>
							</li>
							<li>
								<div class="left w_left">
									Keywords :
								</div>
								<div class="right d_right">
									<%
									if(domain.get("lKeyword")!=null)
									{
										ArrayList<String> arrayList = (ArrayList<String>)domain.get("lKeyword");
										for(int i=0;i<arrayList.size();i++)
										{
									%>
											<a href="/t/<%=arrayList.get(i) %>"><%=arrayList.get(i) %></a> | 
									<%
										}
									}
									%>
									<br/>
									<strong>Length : <%=(domain.get("keyword")!=null)?Utils.returnLength(domain.get("keyword").toString()):"0" %></strong>  characters<br/>
									<strong>Number : <%=(domain.get("keyword")!=null)?Utils.returnNumber(domain.get("keyword").toString()):"0" %></strong>  keywords
								</div>
							</li>
							<li>
								<div class="left w_left">
									Popular Keywords :
								</div>
								<div class="right d_right">
									<%
									if(domain.get("lpKeyword")!=null)
									{
										ArrayList<String> arrayList = (ArrayList<String>)domain.get("lpKeyword");
										for(int i=0;i<arrayList.size();i++)
										{
									%>
											<a href="/t/<%=arrayList.get(i) %>"><%=arrayList.get(i) %></a> | 
									<%
										}
									}
									%>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Description :
								</div>
								<div class="right d_right">
									<%=(domain.get("description")!=null)?domain.get("description"):"-" %><br/>
									<strong>Length : <%=(domain.get("description")!=null)?domain.get("description").toString().length():"0" %></strong>  characters
								</div>
							</li>
						</ul>
					</div>
					<div class="list re_list">
						<h1 class="m_top">Site contact info of <%=domain.get("name") %></h1>
						<ul class="detail">
							<li>
								<div class="left w_left">
									Site's same Google Analytic :<br/>
									<%=(domain.get("googleAnalytics")!=null)?domain.get("googleAnalytics"):"-" %>
								</div>
								<div class="right d_right">
									<%
									if(googleAnalytic != null && googleAnalytic.size()>0)
									{
										while(googleAnalytic.hasNext())
										{
											String name = googleAnalytic.next().get("name").toString();
											out.print("<a href='/d/"+name+"'>"+name+"</a> | ");
										}
									}
									%>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Site's same Google Adsense  :<br/>
									<%=(domain.get("googleAdsense")!=null)?domain.get("googleAdsense"):"-" %>
								</div>
								<div class="right d_right">
									<%
									if(googleAdsense != null && googleAdsense.size()>0)
									{
										while(googleAdsense.hasNext())
										{
											String name = googleAdsense.next().get("name").toString();
											out.print("<a href='/d/"+name+"'>"+name+"</a> | ");
										}
									}
									%>
								</div>
							</li>
						</ul>
					</div>
					<div class="list re_list">
						<h1 class="m_top">Site Technical Info of <%=domain.get("name") %></h1>
						<ul class="detail">
							<li>
								<div class="left w_left">
									Programming Language :
								</div>
								<div class="right d_right">
									<%=(domain.get("language")!=null)?domain.get("language"):"-" %>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Web server :
								</div>
								<div class="right d_right">
									<%=(domain.get("server")!=null)?domain.get("server"):"-" %>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Javascript library  :
								</div>
								<div class="right d_right">
									<%=(domain.get("js")!=null)?Utils.returnString(domain.get("js").toString(),""):"-" %>
								</div>
							</li>
							<li>
								<div class="left w_left">
									IP Address  :<br/>
									<%=(domain.get("ip")!=null)?"<a href='/i/"+domain.get("ip")+"'>"+domain.get("ip")+"</a>":"-" %>
								</div>
								<div class="right d_right">
									<%
									if(ip != null && ip.size()>0)
									{
										while(ip.hasNext())
										{
											String name = ip.next().get("name").toString();
											out.print("<a href='/d/"+name+"'>"+name+"</a> | ");
										}
									}
									%>
								</div>
							</li>
						</ul>
					</div>
					<%
					if(domain.get("ip")!=null)
					{
					%>
					<div class="list re_list">
						<h1 class="m_top">Whois ip <a style='color:#0033CC;font-size: 20px;' href='/i/<%=domain.get("ip") %>'><%=domain.get("ip") %></a></h1>
						<ul class="detail">
							<li class="whois">
								<%=(domain.get("wip")!=null)?Utils.returnWhois(domain.get("wip").toString()):"" %>
							</li>
						</ul>
					</div>
					<%
					}
					%>
					<div class="list re_list">
						<h1 class="m_top">Whois <%=domain.get("name") %> ( <a href="/w/<%=domain.get("name")%>">More detail ...</a> )</h1>
						<ul class="detail">
							<li class="whois">
								<%=(domain.get("whois")!=null)?Utils.returnWhois(domain.get("whois").toString()):"" %>
							</li>
						</ul>
					</div>
					<div class="list re_list">
						<h1 class="m_top">DNS Record <%=domain.get("name") %></h1>
						<ul class="detail">
							<li class="whois">
								<%=(domain.get("dig")!=null)?domain.get("dig"):"" %>
							</li>
						</ul>
					</div>
					<div class="list re_list">
						<h1 class="m_top">NSLOOKUP <%=domain.get("name") %></h1>
						<ul class="detail">
							<li class="whois">
								<%=(domain.get("ns")!=null)?domain.get("ns"):"" %>
							</li>
						</ul>
					</div>
					<div class="list re_list">
						<h1 class="m_top">Site Seo of <%=domain.get("name") %></h1>
						<ul class="detail">
							<li>
								<div class="left w_left">
									Tag :
								</div>
								<div class="right d_right">
									<table cellpadding="0" cellspacing="0" class="l_tag">
										<tr>
											<th>H1</th>
											<th>H2</th>
											<th>H3</th>
											<th>H4</th>
											<th>H5</th>
										</tr>
										<tr>
											<th><%=(domain.get("h1")!=null)?domain.get("h1"):"0" %></th>
											<th><%=(domain.get("h2")!=null)?domain.get("h2"):"0" %></th>
											<th><%=(domain.get("h3")!=null)?domain.get("h3"):"0" %></th>
											<th><%=(domain.get("h4")!=null)?domain.get("h4"):"0" %></th>
											<th><%=(domain.get("h5")!=null)?domain.get("h5"):"0" %></th>
										</tr>
									</table>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Image :
								</div>
								<div class="right d_right">
									We found <b><%=(domain.get("img")!=null)?domain.get("img"):"-" %></b> images on this website.
									<%=(domain.get("altImg")!=null)?"<br/>There are <b>"+domain.get("altImg")+" </b>images alt attribute":"-" %>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Frame  :
								</div>
								<div class="right d_right">
									<b><%=(domain.get("frame")!=null && !domain.get("frame").equals(0))?domain.get("frame"):"No" %></b> 
								</div>
							</li>
							<li>
								<div class="left w_left">
									Flash  :
								</div>
								<div class="right d_right">
									<b><%=(domain.get("flash")!=null && !domain.get("flash").equals(0))?domain.get("flash"):"No" %></b> 
								</div>
							</li>
							<li>
								<div class="left w_left">
									Size  :
								</div>
								<div class="right d_right">
									<b><%=(domain.get("size")!=null)?nf.format(domain.get("size"))+" characters":"-" %></b>
								</div>
							</li>	
							<li>
								<div class="left w_left">
									Meta Description  :
								</div>
								<div class="right d_right">
									<b><%=(domain.get("metaDesc")!=null && domain.get("metaDesc").equals(1))?"Yes":"No" %></b>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Meta Keyword  :
								</div>
								<div class="right d_right">
									<b><%=(domain.get("metaKey")!=null && domain.get("metaKey").equals(1))?"Yes":"No" %></b>
								</div>
							</li>
						</ul>
					</div>
					<div class="list re_list">
						<h1 class="m_top">Cross link of <%=domain.get("name") %></h1>
						<ul class="detail">
							<li>
								<div class="left w_left">
									Out link :
								</div>
								<div class="right d_right">
									<%
										if(domain.get("link")!=null)
										{
											out.print(Utils.returnString(domain.get("link").toString(),"d"));
										}
									%>
								</div>
							</li>
							<li>
								<div class="left w_left">
									Back link :
								</div>
								<div class="right d_right">
									<%
									if(inlink != null && inlink.size()>0)
									{
										while(inlink.hasNext())
										{
											String name = inlink.next().get("name").toString();
											out.print("<a href='/d/"+name+"' >"+name+"</a> | ");
										}
									}
									%>
								</div>
							</li>
						</ul>
					</div>		
					<%
					if(domain.get("rank") != null && Integer.valueOf(domain.get("rank").toString()) < 110000)
					{
					%>
						<div class="list re_list">
							<h1 class="m_top">Domain Traffic Graph of <%=domain.get("name") %></h1>
							<ul class="detail">
								<li>
									<div class="daily left">Daily Rank</div>
									<div class="daily right">Daily PageViews</div>
									<img class="left" src="http://traffic.alexa.com/graph?c=1&amp;u=<%=domain.get("name") %>&amp;r=6m&amp;y=t&amp;z=3&amp;h=200&amp;w=280&amp;b=FFFFFF">
									<img class="right" src="http://traffic.alexa.com/graph?c=1&amp;u=<%=domain.get("name") %>&amp;r=6m&amp;y=r&amp;z=3&amp;h=200&amp;w=280&amp;b=FFFFFF">
									<div class="clear"></div>
								</li>
							</ul>
						</div>	
					<%
					}
					%>	
					<%
					if(domain.get("rank") != null && Integer.valueOf(domain.get("rank").toString()) < 1000000)
					{
					%>
					<div class="list re_list">
						<h1 class="m_top">Unique Visitors of <%=domain.get("name") %></h1>
						<ul class="detail">
							<li  class="full">
								<img class="img_test" src="http://grapher.compete.com/<%=domain.get("name") %>_uv_310.png">
								<ul class="too_domain">
									<%
									while(random.hasNext())
									{
										String name = random.next().get("name").toString();
										out.print("<li><a href='/d/"+name+"'>"+name+"</a> | </li>");
									}
									%>
								</ul>
								<div class="clear"></div>
							</li>
						</ul>
					</div>
					<%
					}
					%>
				</div>
			</div>
			<div class="clear"></div>
		</div>
<div id='opacity'></div>
<img src="/images/ajax-loader.gif" id='image_loadder'/>	
<script type="text/javascript">
	var domain = '<%=domain.get("name")%>';
	
</script>	
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="/js/detail.js"></script>
<script type="text/javascript" src="/js/update.js"></script>	
<%@ include file='/layout/footer.jsp'%>		